Skip to content

Fix #5340: Allow restart of jobs with JobParameterIncrementer from command line#5353

Closed
nikitanagar08 wants to merge 1 commit into
spring-projects:mainfrom
nikitanagar08:fix-5340-parameter-incrementer-restart
Closed

Fix #5340: Allow restart of jobs with JobParameterIncrementer from command line#5353
nikitanagar08 wants to merge 1 commit into
spring-projects:mainfrom
nikitanagar08:fix-5340-parameter-incrementer-restart

Conversation

@nikitanagar08
Copy link
Copy Markdown

@nikitanagar08 nikitanagar08 commented Mar 20, 2026

This PR addresses #5340 by fixing the restart behavior for jobs using JobParameterIncrementer when launched from the command line.

Problem

Previously, when a job with a JobParameterIncrementer was launched from the command line, the start() method would always use the incrementer to create a new instance, even when there was a failed/stopped job instance that could be restarted.

Solution

Modified SimpleJobOperator.start() to:

  1. First try to run the job with the provided parameters (which restarts failed/stopped instances)
  2. Only use the incrementer when JobInstanceAlreadyCompleteException is thrown

Behavior Change

  • Before: Jobs with incrementers always created new instances from command line
  • After: Failed/stopped jobs are restarted; only completed jobs trigger the incrementer

This maintains backward compatibility while enabling the expected restart behavior.


@nikitanagar08 nikitanagar08 force-pushed the fix-5340-parameter-incrementer-restart branch from 9b9099d to c658476 Compare March 20, 2026 16:06
…ementer from command line

This commit addresses the issue where jobs using JobParameterIncrementer
could not be restarted from the command line. Previously, the start()
method would always use the incrementer to create a new instance, even
when there was a failed/stopped job instance that could be restarted.

Changes:
- Modified SimpleJobOperator.start() to first try running the job with
  provided parameters (which restarts failed/stopped instances)
- Only use the incrementer when JobInstanceAlreadyCompleteException
  is thrown (meaning the job instance is already complete)

This allows jobs with JobParameterIncrementer to be restarted from the
command line when they fail or stop, while still creating new instances
when the previous instance is complete.

Signed-off-by: Nikita Nagar <[email protected]>
@nikitanagar08 nikitanagar08 force-pushed the fix-5340-parameter-incrementer-restart branch from c658476 to 2d3d617 Compare March 20, 2026 16:09
@fmbenhassine
Copy link
Copy Markdown
Contributor

Thank you for the PR. As explained in #5340, it is intended to not attempt a restart behind a start operation.

Moreover, this change uses an exception for a normal execution flow (we should not attempt to run the job and then start the next instance if the first attempt throws an exception).

For these reasons, I am closing this PR. Thank you for your time anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants